home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / FZNUM.ZIP / fuzzy / confint / confint.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-03  |  20.4 KB  |  991 lines

  1. //---------------------------------------------------------------------------
  2. //
  3. // CONFINT.H
  4. //
  5. //    Confidence interval type declarations.
  6. //
  7. //    Based on A. Kaufmann, M. Gupta, "Introduction to Fuzzy Arithmetic",
  8. //    Van Nostrand Reinhold, New York, 1991.
  9. //
  10. // Contents:
  11. //
  12. //    class ConfInt
  13. //
  14. //    inline double ConfInt::GetLower()
  15. //    inline double ConfInt::GetUpper()
  16. //    inline double Confint::GetSize()
  17. //
  18. //    inline int ConfInt::operator[]( double value)
  19. //
  20. //    inline ConfInt ConfInt::operator+()
  21. //    inline ConfInt ConfInt::operator-()
  22. //
  23. //    inline ConfInt ConfInt::operator+( double opnd2)
  24. //    inline ConfInt ConfInt::operator+( ConfInt opnd2)
  25. //    inline ConfInt ConfInt::operator-( double opnd2)
  26. //    inline ConfInt ConfInt::operator-( ConfInt opnd2)
  27. //    inline ConfInt ConfInt::operator*( double opnd2)
  28. //    inline ConfInt ConfInt::operator/( double opnd2)
  29. //    inline ConfInt ConfInt::operator/( ConfInt opnd2)
  30. //
  31. //    inline ConfInt ConfInt::operator+=( double opnd2)
  32. //    inline ConfInt ConfInt::operator+=( ConfInt opnd2)
  33. //    inline ConfInt ConfInt::operator-=( double opnd2)
  34. //    inline ConfInt ConfInt::operator-=( ConfInt opnd2)
  35. //    inline ConfInt ConfInt::operator*=( double opnd2)
  36. //    inline ConfInt ConfInt::operator/=( double opnd2)
  37. //    inline ConfInt ConfInt::operator/=( ConfInt opnd2)
  38. //
  39. //    inline ConfInt operator+( double opnd1, ConfInt opnd2)
  40. //    inline ConfInt operator-( double opnd1, ConfInt opnd2)
  41. //    inline ConfInt operator*( double opnd1, ConfInt opnd2)
  42. //
  43. //    inline ostream& operator<<( ostream& smStream, ConfInt ciValue)
  44. //
  45. //    inline ConfInt min( ConfInt opnd1, ConfInt opnd2)
  46. //    inline ConfInt max( ConfInt opnd1, ConfInt opnd2)
  47. //
  48. //    inline double ciDelta( ConfInt opnd1, ConfInt opnd2)
  49. //
  50. // Author: S. Deodato ( 02.03.94)
  51. //
  52. //---------------------------------------------------------------------------
  53.  
  54.  
  55.  
  56. #ifndef ___CONFINT_H
  57. #define ___CONFINT_H
  58.  
  59. #include <iomanip.h>
  60.  
  61. #include <iostream.h>
  62.  
  63. #include <math.h>
  64.  
  65.  
  66. //---------------------------------------------------------------------------
  67. //
  68. // class ConfInt
  69. //
  70. //    Confidence interval representation.
  71. //
  72. // Members:
  73. //
  74. //    double lower
  75. //    double upper
  76. //       lower and upper bounds of the confidence interval
  77. //
  78. // Author: S. Deodato ( 02.03.94)
  79. //
  80. //---------------------------------------------------------------------------
  81.  
  82.  
  83. class ConfInt 
  84.  
  85. {
  86.       double lower;
  87.       double upper;
  88.  
  89.    public:
  90.  
  91.       ConfInt() 
  92.          :  lower( 0),
  93.             upper( 0)
  94.       {}
  95.  
  96.       ConfInt( double value)
  97.          :  lower( value),
  98.             upper( value)
  99.       {}
  100.  
  101.       ConfInt( double lBound, double uBound);
  102.  
  103.       double GetLower();
  104.       double GetUpper();
  105.       double GetSize();
  106.  
  107.       int operator[]( double value);
  108.  
  109.       ConfInt operator+();
  110.       ConfInt operator-();
  111.  
  112.       ConfInt operator+( double opnd2);
  113.       ConfInt operator+( ConfInt opnd2);
  114.       ConfInt operator-( double opnd2);
  115.       ConfInt operator-( ConfInt opnd2);
  116.       ConfInt operator*( double opnd2);
  117.       ConfInt operator*( ConfInt opnd2);
  118.       ConfInt operator/( double opnd2);
  119.       ConfInt operator/( ConfInt opnd2);
  120.  
  121.       ConfInt operator+=( double opnd2);
  122.       ConfInt operator+=( ConfInt opnd2);
  123.       ConfInt operator-=( double opnd2);
  124.       ConfInt operator-=( ConfInt opnd2);
  125.       ConfInt operator*=( double opnd2);
  126.       ConfInt operator*=( ConfInt opnd2);
  127.       ConfInt operator/=( double opnd2);
  128.       ConfInt operator/=( ConfInt opnd2);
  129.  
  130.       friend ConfInt operator+( double opnd1, ConfInt opnd2);
  131.       friend ConfInt operator-( double opnd1, ConfInt opnd2);
  132.       friend ConfInt operator*( double opnd1, ConfInt opnd2);
  133.       friend ConfInt operator/( double opnd1, ConfInt opnd2);
  134.    
  135.       friend ostream& operator<<( ostream& smStream, ConfInt ciValue);
  136.  
  137.       friend ConfInt min( ConfInt opnd1, ConfInt opnd2);
  138.       friend ConfInt max( ConfInt opnd1, ConfInt opnd2);
  139.  
  140.       friend ConfInt sin( ConfInt opnd);
  141.       friend ConfInt cos( ConfInt opnd);
  142.  
  143.       friend double ciDelta( ConfInt opnd1, ConfInt opnd2);
  144. };
  145.  
  146.  
  147. //---------------------------------------------------------------------------
  148. //
  149. // inline double ConfInt::GetLower()
  150. //
  151. //    Return the lower bound of the confidence interval.
  152. //
  153. // Arguments:
  154. //
  155. //    none
  156. //
  157. // Return value:
  158. //
  159. //    the requested lower bound
  160. //
  161. // Side effects:
  162. //
  163. //    none
  164. //
  165. // Author: S. Deodato ( 02.03.94)
  166. //
  167. //---------------------------------------------------------------------------
  168.  
  169. inline double ConfInt::GetLower()
  170.  
  171. {
  172.    return lower;
  173. }
  174.  
  175.  
  176. //---------------------------------------------------------------------------
  177. //
  178. // inline double ConfInt::GetUpper()
  179. //
  180. //    Return the upper bound of the confidence interval.
  181. //
  182. // Arguments:
  183. //
  184. //    none
  185. //
  186. // Return value:
  187. //
  188. //    the requested upper bound
  189. //
  190. // Side effects:
  191. //
  192. //    none
  193. //
  194. // Author: S. Deodato ( 02.03.94)
  195. //
  196. //---------------------------------------------------------------------------
  197.  
  198. inline double ConfInt::GetUpper()
  199.  
  200. {
  201.    return upper;
  202. }
  203.  
  204.  
  205. //---------------------------------------------------------------------------
  206. //
  207. // inline double ConfInt::GetSize()
  208. //
  209. //    Return the size of the confidence interval.
  210. //
  211. // Arguments:
  212. //
  213. //    none
  214. //
  215. // Return value:
  216. //
  217. //    the requested size
  218. //
  219. // Side effects:
  220. //
  221. //    none
  222. //
  223. // Author: S. Deodato ( 26.08.94)
  224. //
  225. //---------------------------------------------------------------------------
  226.  
  227. inline double ConfInt::GetSize()
  228.  
  229. {
  230.    return ( upper - lower);
  231. }
  232.  
  233.  
  234. //---------------------------------------------------------------------------
  235. //
  236. // inline int ConfInt::operator[]( double value)
  237. //
  238. //    Overload the subscripting operator to test the belonging of a given
  239. //    value to the confidence interval.
  240. //
  241. // Arguments:
  242. //
  243. //    double value
  244. //       the value to be tested
  245. //
  246. // Return value:
  247. //
  248. //    the result of the test
  249. //
  250. // Side effects:
  251. //
  252. //    none
  253. //
  254. // Author: S. Deodato ( 27.08.94)
  255. //
  256. //---------------------------------------------------------------------------
  257.  
  258. inline int ConfInt::operator[]( double value)
  259.  
  260. {
  261.    return ( value >= lower && value <= upper);
  262. }
  263.  
  264.  
  265. //---------------------------------------------------------------------------
  266. //
  267. // inline ConfInt ConfInt::operator+()
  268. //
  269. //    Apply the unary plus operator to a confidence interval.
  270. //
  271. // Arguments:
  272. //
  273. //    none
  274. //
  275. // Return value:
  276. //
  277. //    the resulting confidence interval
  278. //
  279. // Side effects:
  280. //
  281. //    none
  282. //
  283. // Author: S. Deodato ( 02.03.94)
  284. //
  285. //---------------------------------------------------------------------------
  286.  
  287. inline ConfInt ConfInt::operator+()
  288.  
  289. {
  290.    return *this;
  291. }
  292.  
  293.  
  294. //---------------------------------------------------------------------------
  295. //
  296. // inline ConfInt ConfInt::operator-()
  297. //
  298. //    Apply the unary minus operator to a confidence interval.
  299. //
  300. // Arguments:
  301. //
  302. //    none
  303. //
  304. // Return value:
  305. //
  306. //    the resulting confidence interval
  307. //
  308. // Side effects:
  309. //
  310. //    none
  311. //
  312. // Author: S. Deodato ( 02.03.94)
  313. //
  314. //---------------------------------------------------------------------------
  315.  
  316. inline ConfInt ConfInt::operator-()
  317.  
  318. {
  319.    return ConfInt( -upper, -lower);
  320. }
  321.  
  322.  
  323. //---------------------------------------------------------------------------
  324. //
  325. // inline ConfInt ConfInt::operator+( double opnd2)
  326. //
  327. //    Addiction between a confidence interval and a singleton.
  328. //
  329. // Arguments:
  330. //
  331. //    double opnd2
  332. //       the singleton to add
  333. //
  334. // Return value:
  335. //
  336. //    the resulting confidence interval
  337. //
  338. // Side effects:
  339. //
  340. //    none
  341. //
  342. // Author: S. Deodato ( 02.03.94)
  343. //
  344. //---------------------------------------------------------------------------
  345.  
  346. inline ConfInt ConfInt::operator+( double opnd2)
  347.  
  348. {
  349.    return ConfInt( lower + opnd2, upper + opnd2);
  350. }
  351.  
  352.  
  353. //---------------------------------------------------------------------------
  354. //
  355. // inline ConfInt ConfInt::operator+( ConfInt opnd2)
  356. //
  357. //    Addiction between two confidence intervals.
  358. //
  359. // Arguments:
  360. //
  361. //    ConfInt opnd2
  362. //       the confidence interval to add
  363. //
  364. // Return value:
  365. //
  366. //    the resulting confidence interval
  367. //
  368. // Side effects:
  369. //
  370. //    none
  371. //
  372. // Author: S. Deodato ( 02.03.94)
  373. //
  374. //---------------------------------------------------------------------------
  375.  
  376. inline ConfInt ConfInt::operator+( ConfInt opnd2)
  377.  
  378. {
  379.    return ConfInt( lower + opnd2.lower, upper + opnd2.upper);
  380. }
  381.  
  382.  
  383. //---------------------------------------------------------------------------
  384. //
  385. // inline ConfInt ConfInt::operator-( double opnd2)
  386. //
  387. //    Subtraction between a confidence interval and a singleton.
  388. //
  389. // Arguments:
  390. //
  391. //    double opnd2
  392. //       the singleton to subtract
  393. //
  394. // Return value:
  395. //
  396. //    the resulting confidence interval
  397. //
  398. // Side effects:
  399. //
  400. //    none
  401. //
  402. // Author: S. Deodato ( 02.03.94)
  403. //
  404. //---------------------------------------------------------------------------
  405.  
  406. inline ConfInt ConfInt::operator-( double opnd2)
  407.  
  408. {
  409.    return ConfInt( lower - opnd2, upper - opnd2);
  410. }
  411.  
  412.  
  413. //---------------------------------------------------------------------------
  414. //
  415. // inline ConfInt ConfInt::operator-( ConfInt opnd2)
  416. //
  417. //    Subtraction between two confidence intervals.
  418. //
  419. // Arguments:
  420. //
  421. //    ConfInt opnd2
  422. //       the confidence interval to subtract
  423. //
  424. // Return value:
  425. //
  426. //    the resulting confidence interval
  427. //
  428. // Side effects:
  429. //
  430. //    none
  431. //
  432. // Author: S. Deodato ( 02.03.94)
  433. //
  434. //---------------------------------------------------------------------------
  435.  
  436. inline ConfInt ConfInt::operator-( ConfInt opnd2)
  437.  
  438. {
  439.    return ConfInt( lower - opnd2.upper, upper - opnd2.lower);
  440. }
  441.  
  442.  
  443. //---------------------------------------------------------------------------
  444. //
  445. // inline ConfInt ConfInt::operator*( double opnd2)
  446. //
  447. //    Multiplication between a confidence interval and a singleton.
  448. //
  449. // Arguments:
  450. //
  451. //    double opnd2
  452. //       the singleton to multiply for
  453. //
  454. // Return value:
  455. //
  456. //    the resulting confidence interval
  457. //
  458. // Side effects:
  459. //
  460. //    none
  461. //
  462. // Author: S. Deodato ( 02.03.94)
  463. //
  464. //---------------------------------------------------------------------------
  465.  
  466. inline ConfInt ConfInt::operator*( double opnd2)
  467.  
  468. {
  469.    return ConfInt( opnd2 * (( opnd2 >= 0) ? lower : upper),
  470.                    opnd2 * (( opnd2 >= 0) ? upper : lower));
  471. }
  472.  
  473.  
  474. //---------------------------------------------------------------------------
  475. //
  476. // inline ConfInt ConfInt::operator/( double opnd2)
  477. //
  478. //    Division between a confidence interval and a singleton.
  479. //
  480. // Arguments:
  481. //
  482. //    double opnd2
  483. //       the singleton to divide for
  484. //
  485. // Return value:
  486. //
  487. //    the resulting confidence interval
  488. //
  489. // Side effects:
  490. //
  491. //    none
  492. //
  493. // Author: S. Deodato ( 02.03.94)
  494. //
  495. //---------------------------------------------------------------------------
  496.  
  497. inline ConfInt ConfInt::operator/( double opnd2)
  498.  
  499. {
  500.    return *this * ( 1 / opnd2);
  501. }
  502.  
  503.  
  504. //---------------------------------------------------------------------------
  505. //
  506. // inline ConfInt ConfInt::operator/( ConfInt opnd2)
  507. //
  508. //    Division between two confidence intervals.
  509. //
  510. // Arguments:
  511. //
  512. //    ConfInt opnd2
  513. //       the confidence interval to divide for
  514. //
  515. // Return value:
  516. //
  517. //    the resulting confidence interval
  518. //
  519. // Side effects:
  520. //
  521. //    none
  522. //
  523. // Author: S. Deodato ( 02.03.94)
  524. //
  525. //---------------------------------------------------------------------------
  526.  
  527. inline ConfInt ConfInt::operator/( ConfInt opnd2)
  528.  
  529. {
  530.    return *this * ( 1 / opnd2);
  531. }
  532.  
  533.  
  534. //---------------------------------------------------------------------------
  535. //
  536. // inline ConfInt ConfInt::operator+=( double opnd2)
  537. //
  538. //    Addiction and assignment between a confidence interval and a
  539. //    singleton.
  540. //
  541. // Arguments:
  542. //
  543. //    double opnd2
  544. //       the singleton to add
  545. //
  546. // Return value:
  547. //
  548. //    the resulting confidence interval
  549. //
  550. // Side effects:
  551. //
  552. //    updates the current confidence interval
  553. //
  554. // Author: S. Deodato ( 02.03.94)
  555. //
  556. //---------------------------------------------------------------------------
  557.  
  558. inline ConfInt ConfInt::operator+=( double opnd2)
  559.  
  560. {
  561.    lower += opnd2;
  562.    upper += opnd2;
  563.  
  564.    return *this;
  565. }
  566.  
  567.  
  568. //---------------------------------------------------------------------------
  569. //
  570. // inline ConfInt ConfInt::operator+=( ConfInt opnd2)
  571. //
  572. //    Addiction and assignment between two confidence intervals.
  573. //
  574. // Arguments:
  575. //
  576. //    ConfInt opnd2
  577. //       the confidence interval to add
  578. //
  579. // Return value:
  580. //
  581. //    the resulting confidence interval
  582. //
  583. // Side effects:
  584. //
  585. //    updates the current confidence interval
  586. //
  587. // Author: S. Deodato ( 02.03.94)
  588. //
  589. //---------------------------------------------------------------------------
  590.  
  591. inline ConfInt ConfInt::operator+=( ConfInt opnd2)
  592.  
  593. {
  594.    lower += opnd2.lower;
  595.    upper += opnd2.upper;
  596.  
  597.    return *this;
  598. }
  599.  
  600.  
  601. //---------------------------------------------------------------------------
  602. //
  603. // inline ConfInt ConfInt::operator-=( double opnd2)
  604. //
  605. //    Subtraction and assignment between a confidence interval and a
  606. //    singleton.
  607. //
  608. // Arguments:
  609. //
  610. //    double opnd2
  611. //       the singleton to subtract
  612. //
  613. // Return value:
  614. //
  615. //    the resulting confidence interval
  616. //
  617. // Side effects:
  618. //
  619. //    updates the current confidence interval
  620. //
  621. // Author: S. Deodato ( 02.03.94)
  622. //
  623. //---------------------------------------------------------------------------
  624.  
  625. inline ConfInt ConfInt::operator-=( double opnd2)
  626.  
  627. {
  628.    lower -= opnd2;
  629.    upper -= opnd2;
  630.  
  631.    return *this;
  632. }
  633.  
  634.  
  635. //---------------------------------------------------------------------------
  636. //
  637. // inline ConfInt ConfInt::operator-=( ConfInt opnd2)
  638. //
  639. //    Subtraction and assignment between two confidence intervals.
  640. //
  641. // Arguments:
  642. //
  643. //    ConfInt opnd2
  644. //       the confidence interval to subtract
  645. //
  646. // Return value:
  647. //
  648. //    the resulting confidence interval
  649. //
  650. // Side effects:
  651. //
  652. //    updates the current confidence interval
  653. //
  654. // Author: S. Deodato ( 02.03.94)
  655. //
  656. //---------------------------------------------------------------------------
  657.  
  658. inline ConfInt ConfInt::operator-=( ConfInt opnd2)
  659.  
  660. {
  661.    lower -= opnd2.upper;
  662.    upper -= opnd2.lower;
  663.  
  664.    return *this;
  665. }
  666.  
  667.  
  668. //---------------------------------------------------------------------------
  669. //
  670. // inline ConfInt ConfInt::operator*=( double opnd2)
  671. //
  672. //    Multiplication and assignment between a confidence interval and a
  673. //    singleton.
  674. //
  675. // Arguments:
  676. //
  677. //    double opnd2
  678. //       the singleton to multiply for
  679. //
  680. // Return value:
  681. //
  682. //    the resulting confidence interval
  683. //
  684. // Side effects:
  685. //
  686. //    updates the current confidence interval
  687. //
  688. // Author: S. Deodato ( 02.03.94)
  689. //
  690. //---------------------------------------------------------------------------
  691.  
  692. inline ConfInt ConfInt::operator*=( double opnd2)
  693.  
  694. {
  695.    double tmp = lower;
  696.    lower = opnd2 * (( opnd2 >= 0) ? lower : upper);
  697.    upper = opnd2 * (( opnd2 >= 0) ? upper : tmp);
  698.  
  699.    return *this;
  700. }
  701.  
  702.  
  703. //---------------------------------------------------------------------------
  704. //
  705. // inline ConfInt ConfInt::operator/=( double opnd2)
  706. //
  707. //    Division and assignment between a confidence interval and a singleton.
  708. //
  709. // Arguments:
  710. //
  711. //    double opnd2
  712. //       the singleton to divide for
  713. //
  714. // Return value:
  715. //
  716. //    the resulting confidence interval
  717. //
  718. // Side effects:
  719. //
  720. //    updates the current confidence interval
  721. //
  722. // Author: S. Deodato ( 02.03.94)
  723. //
  724. //---------------------------------------------------------------------------
  725.  
  726. inline ConfInt ConfInt::operator/=( double opnd2)
  727.  
  728. {
  729.    return *this *= ( 1 / opnd2);
  730. }
  731.  
  732.  
  733. //---------------------------------------------------------------------------
  734. //
  735. // inline ConfInt ConfInt::operator/=( ConfInt opnd2)
  736. //
  737. //    Division and assignment between two confidence intervals.
  738. //
  739. // Arguments:
  740. //
  741. //    ConfInt opnd2
  742. //       the confidence interval to divide for
  743. //
  744. // Return value:
  745. //
  746. //    the resulting confidence interval
  747. //
  748. // Side effects:
  749. //
  750. //    updates the current confidence interval
  751. //
  752. // Author: S. Deodato ( 02.03.94)
  753. //
  754. //---------------------------------------------------------------------------
  755.  
  756. inline ConfInt ConfInt::operator/=( ConfInt opnd2)
  757.  
  758. {
  759.    return *this *= ( 1 / opnd2);
  760. }
  761.  
  762.  
  763. //---------------------------------------------------------------------------
  764. //
  765. // inline ConfInt operator+( double opnd1, ConfInt opnd2)
  766. //
  767. //    Sum a singleton to a confidence interval.
  768. //
  769. // Arguments:
  770. //
  771. //    double opnd1
  772. //    ConfInt opnd2
  773. //       the operands
  774. //
  775. // Return value:
  776. //
  777. //    the resulting confidence interval
  778. //
  779. // Side effects:
  780. //
  781. //    none
  782. //
  783. // Author: S. Deodato ( 02.03.94)
  784. //
  785. //---------------------------------------------------------------------------
  786.  
  787. inline ConfInt operator+( double opnd1, ConfInt opnd2)
  788.  
  789. {
  790.    return opnd2 + opnd1;
  791. }
  792.  
  793.  
  794. //---------------------------------------------------------------------------
  795. //
  796. // inline ConfInt operator-( double opnd1, ConfInt opnd2)
  797. //
  798. //    Subtract from a singleton a confidence interval.
  799. //
  800. // Arguments:
  801. //
  802. //    double opnd1
  803. //    ConfInt opnd2
  804. //       the operands
  805. //
  806. // Return value:
  807. //
  808. //    the resulting confidence interval
  809. //
  810. // Side effects:
  811. //
  812. //    none
  813. //
  814. // Author: S. Deodato ( 02.03.94)
  815. //
  816. //---------------------------------------------------------------------------
  817.  
  818. inline ConfInt operator-( double opnd1, ConfInt opnd2)
  819.  
  820. {
  821.    return -opnd2 + opnd1;
  822. }
  823.  
  824.  
  825. //---------------------------------------------------------------------------
  826. //
  827. // inline ConfInt operator*( double opnd1, ConfInt opnd2)
  828. //
  829. //    Multiply a singleton for a confidence interval.
  830. //
  831. // Arguments:
  832. //
  833. //    double opnd1
  834. //    ConfInt opnd2
  835. //       the operands
  836. //
  837. // Return value:
  838. //
  839. //    the resulting confidence interval
  840. //
  841. // Side effects:
  842. //
  843. //    none
  844. //
  845. // Author: S. Deodato ( 02.03.94)
  846. //
  847. //---------------------------------------------------------------------------
  848.  
  849. inline ConfInt operator*( double opnd1, ConfInt opnd2)
  850.  
  851. {
  852.    return opnd2 * opnd1;
  853. }
  854.  
  855.  
  856. //---------------------------------------------------------------------------
  857. //
  858. // inline ostream& operator<<( ostream& smStream, ConfInt ciValue)
  859. //
  860. //    Write a confidence interval into an output stream.
  861. //
  862. // Arguments:
  863. //
  864. //    ostream& smStream
  865. //       reference to the used output stream
  866. //
  867. //    ConfInt ciValue
  868. //       confidence interval to write
  869. //
  870. // Return value:
  871. //
  872. //    reference to the used output stream
  873. //
  874. // Side effects:
  875. //
  876. //    none
  877. //
  878. // Author: S. Deodato ( 02.03.94)
  879. //
  880. //---------------------------------------------------------------------------
  881.  
  882. inline ostream& operator<<( ostream& smStream, ConfInt ciValue)
  883.  
  884. {
  885.    return smStream << "[ " << setprecision( 6) << ciValue.lower
  886.                    << ", " << setprecision( 6) << ciValue.upper << "]";
  887. }
  888.  
  889.  
  890. //---------------------------------------------------------------------------
  891. //
  892. // inline ConfInt min( ConfInt opnd1, ConfInt opnd2)
  893. //
  894. //    Calculate the minimum confidence interval from two given ones.
  895. //
  896. // Arguments:
  897. //
  898. //    ConfInt opnd1
  899. //    ConfInt opnd2
  900. //       the operands
  901. //
  902. // Return value:
  903. //
  904. //    the computed minimum confidence interval
  905. //
  906. // Side effects:
  907. //
  908. //    none
  909. //
  910. // Author: S. Deodato ( 12.03.94)
  911. //
  912. //---------------------------------------------------------------------------
  913.  
  914. inline ConfInt min( ConfInt opnd1, ConfInt opnd2)
  915.  
  916. {
  917.    return ConfInt( ( opnd1.lower <= opnd2.lower) ? opnd1.lower
  918.                                                  : opnd2.lower,
  919.                    ( opnd1.upper <= opnd2.upper) ? opnd1.upper
  920.                                                  : opnd2.upper);
  921. }
  922.  
  923.  
  924. //---------------------------------------------------------------------------
  925. //
  926. // inline ConfInt max( ConfInt opnd1, ConfInt opnd2)
  927. //
  928. //    Calculate the maximum confidence interval from two given ones.
  929. //
  930. // Arguments:
  931. //
  932. //    ConfInt opnd1
  933. //    ConfInt opnd2
  934. //       the operands
  935. //
  936. // Return value:
  937. //
  938. //    the computed maximum confidence interval
  939. //
  940. // Side effects:
  941. //
  942. //    none
  943. //
  944. // Author: S. Deodato ( 12.03.94)
  945. //
  946. //---------------------------------------------------------------------------
  947.  
  948. inline ConfInt max( ConfInt opnd1, ConfInt opnd2)
  949.  
  950. {
  951.    return ConfInt( ( opnd1.lower >= opnd2.lower) ? opnd1.lower
  952.                                                  : opnd2.lower,
  953.                    ( opnd1.upper >= opnd2.upper) ? opnd1.upper
  954.                                                  : opnd2.upper);
  955. }
  956.  
  957.  
  958. //---------------------------------------------------------------------------
  959. //
  960. // inline double ciDelta( ConfInt opnd1, ConfInt opnd2)
  961. //
  962. //    Calculate the distance between two confidence intervals.
  963. //
  964. // Arguments:
  965. //
  966. //    ConfInt opnd1
  967. //    ConfInt opnd2
  968. //       the two confidence intervals to compare
  969. //
  970. // Return value:
  971. //
  972. //    the computed distance
  973. //
  974. // Side effects:
  975. //
  976. //    none
  977. //
  978. // Author: S. Deodato ( 19.04.94)
  979. //
  980. //---------------------------------------------------------------------------
  981.  
  982. inline double ciDelta( ConfInt opnd1, ConfInt opnd2)
  983.  
  984. {
  985.    return ( fabs( opnd1.lower - opnd2.lower) +
  986.             fabs( opnd1.upper - opnd2.upper));
  987. }
  988.  
  989.  
  990. #endif // ___CONFINT_H
  991.